/*  Copyright 2011 Jason Jones
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package com.jasonwjones.hyperion.jessub;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * Main execution class. Parses parameters, reads in the files, calls the main
 * worker classes to do their thing, and generates the output
 * @author jasonwjones
 *
 */
public class Jessub {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		Map<String, String> parameterValues = new HashMap<String, String>();
		
		if (args.length < 2) {
			printHelp();
			System.exit(1);
		} else if (args.length > 2) {
			for (int argIndex = 2; argIndex < args.length; argIndex++) {
				String arg = args[argIndex];
				if (arg.contains("=")) {
					String[] split = arg.split("=");
					parameterValues.put(split[0], split[1]);
				}
			}
		}
		
		String inputFile = args[0];
		String outputFile = args[1];
		
		Replacer replacer = new Replacer();
		
		try {
			replacer.process(inputFile, outputFile);
		} catch (IOException e) {
			System.out.println("Error: " + e.getMessage());
		}

	}
	
	/**
	 * Printed if Jessub is not run with the proper parameters
	 */
	public static void printHelp() {
		System.out.println("Please run with file names...");
	}

}
